import { defineConfig } from 'vite'
import path from "path";
import vue from '@vitejs/plugin-vue'
// 暂时取消electron 打包出现问题
// import electron from 'vite-plugin-electron';
// import electronRenderer from 'vite-plugin-electron/renderer';
// import polyfillExports from 'vite-plugin-electron/polyfill-exports';

export default defineConfig({
  resolve: {
    alias: [
      {
        find: '@',
        replacement: path.resolve(__dirname, 'src')
      },
      {
        find: 'components',
        replacement: path.resolve(__dirname, 'src/components')
      },
      {
        find: 'interface',
        replacement: path.resolve(__dirname, 'src/interface')
      },
    ],
  },
  plugins: [
    vue(),
    // electron({
    //   main: {
    //     entry: 'electron-main/index.ts',
    //   },
    //   preload: {
    //     // Must be use absolute path, this is the limit of rollup
    //     input: path.join(__dirname, './electron-preload/index.ts'),
    //   },
    // }),
    // electronRenderer(),
    // polyfillExports(),
  ],
  build: {
    emptyOutDir: false, // 必须配置，否则electron相关文件将不会生成build后的文件
  },
  server: {
    proxy: {
      '/api': {
        target: "http://localhost:3010/api",          //这个是你要访问得接口地址  测试服
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    },
  },
})

